<template>
    <!-- 推荐专区 -->
    <div class="panel hot">
      <div class="item" v-for="(item, index) in recommends" :key="index">
        <div class="title">
          <span class="title-text">{{ item.title }}</span>
          <span class="title-desc">>{{ item.alt }}</span>
        </div>
        <div class="cards" @click="$router.push('/recommend?type='+item.type)">
          <van-image
            v-for="(good, index) in item.goods" :key="index"
            class="image"
            :src="global.MINIO_FILE_DOMAIN + good.cover_url"
          ></van-image>
        </div>
      </div>
    </div>
</template>

<script setup lang="ts">
import { inject } from 'vue'
defineProps({
    'recommends': {
        type: Array,
        default: []
    }
})

// 全局属性
const global:any = inject('global')
</script>
  
<style lang="scss">
  /* 热门推荐 */
  .hot {
    display: flex;
    flex-wrap: wrap;
    min-height: 254px;
    margin: 10px 10px 0;
    border-radius: 5px;
    background-color: #fff;
  
    .title {
      display: flex;
      align-items: center;
      padding: 12px 12px 0;
      font-size: 16px;
      color: #262626;
      position: relative;
      .title-desc {
        font-size: 12px;
        color: #7f7f7f;
        margin-left: 18rpx;
      }
    }
  
    .item {
      display: flex;
      flex-direction: column;
      width: 50%;
      height: 127px;
      border-right: 1px solid #eee;
      border-top: 1px solid #eee;
      .title {
        justify-content: start;
      }
      &:nth-child(2n) {
        border-right: 0 none;
      }
      &:nth-child(-n + 2) {
        border-top: 0 none;
      }
    }
    .cards {
      flex: 1;
      padding: 8px 10px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      .image {
        width: 75px;
        height: 75px;
      }
    }
  }
</style>